<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .sliderbar {
            position: absolute;
            float: right;
            right: 0px;
            width: 440px;
            height: 40px;
        }
        
        span {
            position: absolute;
            float: left;
            width: 40px;
            height: 40px;
            right: 200px;
            background-color: pink;
            z-index: 999;
            /* align-items: center; */
        }
        
        .con {
            position: absolute;
            float: left;
            height: 40px;
            width: 200px;
            right: 0px;
            background-color: khaki;
            z-index: -99999;
        }
    </style>
</head>

<body>
    <div class="sliderbar">
        <span><-</span>
        <div class="con">问题反馈</div>
    </div>
    <script>
        var sliderbar = document.querySelector(".sliderbar");
        var con = document.querySelector(".con");
        var span = document.querySelector("span");

        function animate_2(obj, target, callback) {
            clearInterval(obj.timer); //pi'mia避免一个obj绑定多个定时器

            obj.timer = setInterval(function() { //给具体obj绑定定时器 节省空间
                // var step = Math.ceil((target - obj.offsetLeft) / 10);
                var step = (target - obj.offsetLeft) / 10;
                step > 0 ? Math.ceil(step) : Math.floor(step);
                if (obj.offsetLeft == target) {
                    clearInterval(obj.timer);
                }
                obj.style.left = obj.offsetLeft + step + 'px';
                if (callback) {
                    callback();
                }

            }, 30);
        };
        span.addEventListener('mouseenter', function() {
            animate_2(con, 0, function() {
                span.innerHTML = "->";
            });
        });
        span.addEventListener('mouseleave', function() {
            animate_2(con, 243, function() {
                span.innerHTML = "<-";
            });
        })
    </script>
</body>

</html>